home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_13.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  3KB  |  116 lines

  1. program GSDMO_13;
  2. {------------------------------------------------------------------------------
  3.                          DBase Relational File Linkage
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        20 January 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This unit demonstrates how to search for multiple records with a
  14.        common identifier.
  15.  
  16.        The master file index is on the LASTNAME+FIRSTNAME fields.  The
  17.        transaction record is located by matching the master record UNIQUEID
  18.        to the MASTERID field of the transaction record.
  19.  
  20.        The routine will read each master record and list all transactions
  21.        with the master record unique identifier.
  22.  
  23. -------------------------------------------------------------------------------}
  24.  
  25. uses
  26.    GSOB_Str,
  27.    GSOBShel,
  28.    {$IFDEF WINDOWS}
  29.       WinCRT,
  30.       WinDOS;
  31.    {$ELSE}
  32.       CRT,
  33.       DOS;
  34.    {$ENDIF}
  35.  
  36.  
  37. var
  38.    ch : char;
  39.    mfileid : string[8];
  40.  
  41. begin
  42.    ClrScr;
  43.    ch := ' ';
  44.  
  45.    if not FileExist('GSDMO_MF.DBF') then
  46.    begin
  47.       writeln('File GSDMO_MF.DBF not found.  Run GSDMO_11 to create.');
  48.       halt;
  49.    end;
  50.  
  51.    if not FileExist('GSDMO_TF.DBF') then
  52.    begin
  53.       writeln('File GSDMO_TF.DBF not found.  Run GSDMO_11 to create.');
  54.       halt;
  55.    end;
  56.  
  57.                        {The 'Real' example starts here}
  58.  
  59.    Select(1);
  60.    Use('GSDMO_MF');
  61.    Index('GSDMO_NM');
  62.    Select(2);
  63.    Use('GSDMO_TF');
  64.    Index('GSDMO_TN');
  65.  
  66.    Select(1);
  67.    GoTop;
  68.    while not (dEOF) and (Ch <> #27) do
  69.    begin
  70.       ClrScr;
  71.       mfileid := FieldGet('UNIQUEID');
  72.                    {Display the master record}
  73.  
  74.       Writeln('':37,'MASTER');
  75.       Writeln;
  76.       Writeln('  LASTNAME : ',FieldGet('LASTNAME'));
  77.       Writeln(' FIRSTNAME : ',FieldGet('FIRSTNAME'));
  78.       Writeln('    STREET : ',FieldGet('STREET'));
  79.       Writeln('   ADDRESS : ',StringGet('CITY'),', ',
  80.                               FieldGet('STATE'),' ',
  81.                               FieldGet('ZIP'));
  82.  
  83.                        {Display transaction information}
  84.  
  85.       Writeln;
  86.       Writeln('':20,'-----------------------------------------');
  87.       Writeln('':34,'TRANSACTION');
  88.       Writeln;
  89.  
  90.                        {Hunt for matching records}
  91.  
  92.       Select(2);
  93.       Find(mfileid);
  94.       if Found then
  95.       begin
  96.          while ((mfileid) = FieldGet('MASTERID')) and not dEOF do
  97.          begin
  98.             Writeln(FieldGet('FULLNAME'),'  ',
  99.                     DTOC(DateGet('TRANDATE')),'  ',
  100.                     FieldGet('AMOUNT'),'       [',
  101.                     RecNo:2,']');
  102.             Skip(1);
  103.          end;
  104.       end
  105.       else Writeln('No Transaction Records!');
  106.  
  107.       Writeln;
  108.       Writeln('Press Any Key to Continue: ') ;
  109.       Writeln('[ESC] Will Terminate the Program');
  110.       ch := ReadKey;
  111.       Select(1);
  112.       Skip(1);
  113.    end;
  114.    CloseDataBases;
  115. end.
  116.